﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Data;
using System.Data.SqlClient;

namespace ArtsShop.DataLayer.DataAccess
{
    public class ShoppingCartDAO : DataServiceBase
    {
        public ShoppingCartDAO() :base() { }
        public ShoppingCartDAO(System.Data.IDbTransaction txn) : base(txn) { }

        public void addItemToCart(string cartID, int productID, int quantity)
        {
            SqlCommand cmd;
            ExecuteNonQuery(out cmd, "[dbo].[AddItemToCart]",
                CreateParameter("@cartId", SqlDbType.NVarChar, cartID),
                CreateParameter("@productId", SqlDbType.Int, productID),
                CreateParameter("@quantity", SqlDbType.Int, quantity));
            
            cmd.Dispose();
            
        }

        public DataSet getCartProducts(string cartId)
        {
            return ExecuteDataSet("getCartProductsById", CreateParameter("@cartId", SqlDbType.Int, cartId));
        }
    }
}
